{template header}
<div class="container">


<ol class="breadcrumb">
  <li><a href="{SITE_URL}">首页</a></li>
  <li><a href="{tsUrl('ask')}">问答</a></li>
  <li class="active">{$questionstr['title']}</li>
</ol>


<div class="panel panel-default">
  <div class="panel-body">

<div class="row" id="wrap" style="overflow: visible; position: relative;">
<div class="col-md-8">
    <div class="post">
        <h1 id="articleTitle">{$questionstr['title']}</h1>
        <p class="post-tags">
            {loop $questionstr['cate'] $v}
            <a class="tag" href="{tsUrl('ask', 'category', array('cateid'=>{$v['cateid']}))}">{$v['catename']}</a>
            {/loop}
        </p>
        <div class="post-info">
            <span class="post-user">
            <a  href="{tsUrl('group','user',array('id'=>$questionstr['userid']))}" id="articleAuthor" rel="face" uid="$questionstr[userid]">{$questionstr['user']['username']}</a>
            </span>
            <span class="post-date">发表于&nbsp;&nbsp;{$questionstr['addtime']}</span>
        </div>
        <div id="articleContent" class="post-detail">
             {$questionstr['content']}
        </div>

        {if $arrTag}
        <div class="tags">
            {loop $arrTag $key $item}
            <a href="{tsUrl('ask','tag',array('id'=>urlencode($item)))}">{$item}</a>
            {/loop}
        </div>
        {/if}


        {php doAction('gobad','468')}

        
        <div id="questionCmts" class="cmts cmtsBody">
            <div class="cmts-t cmtsTitle">
                <p class="fl">
                    <a class="cmts-num" data-operation="control" href="javascript: void 0;">{if $askaddarr}{php echo count($askaddarr);}条讨论{else}添加讨论{/if}</a>
                    {if ($questionstr['userid']==$TS_USER['userid'])}
                    <span class="split">|</span>
                    <a href="{tsUrl('ask','edit',array('askid'=>$questionstr['askid']))}">修改</a>
                    {/if}
                    
                    {if 1 == $TS_USER['isadmin']}
                    <span class="split">|</span>
                    <a href="{tsUrl('ask','delete',array('askid'=>$questionstr['askid']))}">删除</a>
                    {/if}
                </p>
                <p class="fr">
                    {if ($questionstr['userid']==$TS_USER['userid'])}
	                <a id="closeOrOpenQuestion" data-id="{$askid}" href="javascript:void(0);">{if 0 == $questionstr['isopen']}关闭问题{else}解锁问题{/if}</a>
                    {/if}
                </p>
            </div>
            
            {if 1 == $questionstr['isopen']}
            <div class="cmtsList hide">
                 <ul class="cmts-list">
                 </ul>
                 <div class="cmts-do cmtsDo">
                     <p>
                                                        此问题目前不允许回应
                     </p>
                 </div>
             </div>
             {else}
             <div class="cmtsList" style="display:none">
                 <ul class="cmts-list">
                 {loop $askaddarr $addarr}
                     <li>{$addarr['content']} - <a  href="{tsUrl('user','topic',array('id'=>$addarr['userid']))}">{$addarr['username']}</a> {$addarr['addtime']}
                     {if $addarr['userid'] == $TS_USER['userid']}
                     <a class="cmts-list-d" data-operation="deleteCmt" data-id="{$addarr['replyid']}" href="javascript:void 0">删除</a>
                     {/if}
                     </li>
                 {/loop}
                 </ul>
                 <div class="cmts-do cmtsDo">
                     <textarea class="b_txt" cols="30" rows="10" name="cmt"></textarea>
                     <p>
                         <input type="button" data-type="question" data-id="{$askid}" data-operation="newCmt" class="mw_btn" value="讨论">
                     </p>
                 </div>
             </div>
             {/if}
        </div>
        
    </div>

    <div class="document-do">
        <div id="share" class="fl">
     
        </div>
        <div class="fr">
            
        <a class="sg_btn-ext" href="#answerReplyer" id="goToEditor">
            <!--[if lte IE 7]><b class="sg_btn-ext-b"></b><![endif]-->
           <span>添加答案</span>
           <!--[if lte IE 7]><b class="sg_btn-ext-a"></b><![endif]-->
            </a>
            
        </div>
        </div>
        <div id="answers" class="answers">
            <div class="main-title-b">
                <div class="main-title">
                <h2>{if 0 == $questionstr['count']}没有答案{else}{$questionstr['count']}个答案{/if}</h2>

                <p class="answers-t-r">
                    {if ''!=$orderflag}
                    <a href="{tsUrl('ask', 'question', array('id'=>{$askid}))}">按投票排序</a>
                    <span class="split">|</span>
                    <span>按时间排序</span>
                    {else} 
                    <span>按投票排序</span>
                    <span class="split">|</span>
                    <a href="{tsUrl('ask', 'question', array('id'=>{$askid}, 'orderby'=>'date'))}">按时间排序</a>
                    {/if}
			    </p>
			    </div>
			</div>
        
       {loop $commentarr $v}   
       <div id="answer{$v['commentid']}" class="answer{if $v['userid']==$TS_USER['userid']} highlight{/if}">
            <div class="answer-digg digg">
                <a title="支持(+1)" class="answer-digg-up" data-id="{$v['commentid']}" data-user="{$v['userid']}" data-cur="{$TS_USER['userid']}" href="javascript:void 0;"><s></s>顶</a>
                <a title="反对(-1)" class="answer-digg-dw" data-id="{$v['commentid']}" data-user="{$v['userid']}" data-cur="{$TS_USER['userid']}" href="javascript:void 0;"><s></s>踩</a>
            </div>
            <div class="answer-r">
	            <div class="answer-t">
	                <a  title="{$v['username']}" href="{tsUrl('user','topic',array('id'=>$v['userid']))}" class="answer-img">
	                    <img width="24" height="24" src="<!--{if $v['face']==''}-->{SITE_URL}public/images/user_normal.jpg<!--{else}-->{php echo tsXimg($v['face'],'user','24','24',$v['path'],'1')}<!--{/if}-->">
	                </a>
	                <p class="answer-usr">
	                    <a  title="{$v['username']}" href="{tsUrl('user','topic',array('id'=>$v['userid']))}" class="answer-usr-name">{$v['username']}</a>
	                </p>
	                <p class="answer-date">{php echo date('Y-m-d H:i:s', $v['addtime']);}</p>
	            </div>
	            <div data-id="{$v['commentid']}" class="answer-diggers diggers">
	            {$v['digg']}支持&nbsp;&nbsp;/&nbsp;&nbsp;{$v['undigg']}反对{if $v['diggarr']}，来自{/if}
	            <span>
	            {loop $v['diggarr'] $k $digg}
	                {if $k < 3}
		                <a href="{tsUrl('user','topic',array('id'=>$digg['userid']))}">$digg['username']</a>
		                {if (count($v['diggarr']) - 1) > $k && $k < 2}、{/if}
	                {/if}
	            {/loop}
	            </span>
	            {if count($v['diggarr']) > 3}
	            <a data-id="" class="expandDiggers" href="javascript:void 0;">更多...</a>
	            <span class="hide">
	                {loop $v['diggarr'] $k $digg}
	                    {if $k > 2}
	                    	、<a href="{tsUrl('user','topic',array('id'=>$digg['userid']))}">$digg['username']</a>
	                    {/if}
	                {/loop}
	            </span>
	            {/if}
	            </div>
	            
	            <script type="text/data" class="hide diggersData">
                    {php echo json_encode(array('dig'=>$v['diggarr'], 'num'=>array('d'=>{$v['digg']}, u=>{$v['undigg']})));}
                </script>
	            <div class="answer-txt answerTxt" id="answer-txt{$v['commentid']}">{$v['comment']}</div>
	            <div class="cmts cmtsBody">
		            <div class="cmts-t cmtsTitle">
		                <p class="fl">
		                    <a class="cmts-num" data-operation="control" href="javascript: void 0;">{if $v['askaddarr']}{php echo count($v['askaddarr']);}条讨论{else}添加讨论{/if}</a>
		                    {if 1 == $TS_USER['isadmin'] || $v['userid']==$TS_USER['userid']}
			                  <span class="split">|</span><a id="deleteAnswer" data-id="{$v['commentid']}" data-operation="deleteAnswer" href="javascript: void 0;">删除</a>
			                {/if}
			                {if $v['userid']==$TS_USER['userid']}
		                    <span class="split">|</span>
		                    <a href="{tsUrl('ask','answeredit',array('commentid'=>$v['commentid']))}">修改</a>
		                    {/if}
		                </p>
		           </div>
	               <div class="cmtsList" style="display:none;">
                        <ul class="cmts-list">
                        {loop $v['askaddarr'] $addarr}
		                     <li>{$addarr['content']} - <a  href="{tsUrl('user','topic',array('id'=>$addarr['userid']))}">{$addarr['username']}</a> {$addarr['addtime']}
		                     {if $addarr['userid'] == $TS_USER['userid']}
		                     <a class="cmts-list-d" data-operation="deleteCmt" data-id="{$addarr['replyid']}" href="javascript:void 0">删除</a>
		                     {/if}
		                     </li>
		                {/loop}
                        </ul>
                        <div class="cmts-do cmtsDo">
                            <textarea class="b_txt" cols="30" rows="10" name="cmt"></textarea>
                            <p>
                                <input type="button" data-type="answer" data-id="{$v['commentid']}" data-operation="newCmt" class="mw_btn" value="讨论">
                            </p>
                        </div>
                    </div>
	           </div>
           </div>
       </div>
       {/loop}
       
       {if $questionstr['count'] > COMMENT_PAGE_NUM}
       <a id="expandAnswer" class="answer-expand" data-id="2" href="javascript:void 0;">显示更多答案</a>
       <input type="hidden" value="{$askid}" id="askid">
       {/if}
   
    {if 1 == $questionstr['isopen']}
	    <div class="post_commet">
	        <p>此问题目前不允许回答</p>
	    </div>
    {else}
    {if $notallowcomment}
    	<div id="answerReplyer" class="post_commet">
             <h4>添加答案</h4>
             <p>每个问题每人仅能回答一次，如需更新请直接修改</p>
        </div>
         
        <div id="edit_ans" style="display:none;">
	        <textarea style="width:560px;height:200px;font-size:14px;" name="content">{$selfcomment}</textarea>
	        <p class="answer-txt-do">
	        <a data-id="{$selfcommentid}" data-operation="cancelEditAnswer" id="cancelEditAnswer" href="javascript: void 0;">取消</a>
	        <a data-operation="editAnswerPush" data-id="{$selfcommentid}" id="editAnswerPush" class="mw_btn" href="javascript: void 0;">确认修改</a>
	        </p>          
        </div>
        
        <div id="edit_original" style="display:none;">{$originalcomment}</div>
        
        <input type="hidden" value="{$orderflag}" name="orderby" id="orderby">
    {else}
	    <div id="answerReplyer" class="post_commet">
	           
	    <div class="post_commet-usr">
	      <a  title="{$TS_USER['username']}" href="{tsUrl('user','topic',array('id'=>$TS_USER['userid']))}">
	          <img width="24" height="24" src="<!--{if $TS_USER['face']==''}-->{SITE_URL}public/images/user_normal.jpg<!--{else}-->{php echo tsXimg($TS_USER['face'],'user','24','24',$TS_USER['path'],'1')}<!--{/if}-->">
	      </a>
	      <span>
	          <a  title="{$TS_USER['username']}" href="{tsUrl('user','topic',array('id'=>$TS_USER['userid']))}">{$TS_USER['username']}</a>
	          
	      </span>
	    </div>
	
	    <form action="{tsUrl('ask', 'answer', array('askid'=>{$askid}))}" method="POST" id="answer_editor">
	        <textarea style="width:100%;font-size:14px;" id="tseditor" name="content"></textarea>            
	        <input type="submit" class="bg_btn" value="新增答案">
	        <input type="hidden" value="{$orderflag}" name="orderby" id="orderby">
	    </form>
	                  
	    </div>
    {/if}
    {/if}
                
    </div>
    </div>
    <div class="col-md-4">
        <div class="side-ask">
                              添加你想要问的问题&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="bg_btn" href="{tsUrl('ask', 'new')}">我要提问</a>
        </div>
                 
 
    <div class="side-title"><h2>你可能感兴趣</h2></div>


        <div class="commlist">
            <ul>
                {loop $arrAsk $v}
                <li>
                    <a href="{tsUrl('ask', 'question', array('id'=>$v['askid']))}" >{$v['title']}</a>
                </li>
                {/loop}
            </ul>
        </div>



        <!--广告位-->
        {php doAction('gobad','300')}
      </div>
  </div>
  </div>
  </div>

  <div class="bottom"></div>
</div>
{php doAction('tseditor','mini')}
{template footer}